
package movdata

import static griffon.util.GriffonApplicationUtils.*
import javax.swing.event.PopupMenuListener
import griffon.builder.css.CSSDecorator



actions {
    action(id: 'newAction',
      name: app.getMessage('application.action.New.name', 'New'),
      closure: controller.newAction,
      mnemonic: app.getMessage('application.action.New.mnemonic', 'N'),
      accelerator: shortcut(app.getMessage('application.action.New.shortcut', 'N')),
      shortDescription: app.getMessage('application.action.New.description', 'New'),
      smallIcon: silkIcon('page_white_cup')
    )

    action(id: 'undoAction',
        name: app.getMessage('application.action.Undo.name', 'Undo'),
        closure: controller.undoAction,
        mnemonic: app.getMessage('application.action.Undo.mnemonic', 'U'),
        accelerator: shortcut(app.getMessage('application.action.Undo.shortcut', 'U')),
        shortDescription: app.getMessage('application.action.Undo.description', 'Undo'),
        smallIcon: silkIcon('page_white_cup')
    )
    action(id: 'redoAction',
        name: app.getMessage('application.action.Redo.name', 'Redo'),
        closure: controller.redoAction,
        mnemonic: app.getMessage('application.action.Undo.mnemonic', 'R'),
        accelerator: shortcut(app.getMessage('application.action.Undo.shortcut', 'R')),
        shortDescription: app.getMessage('application.action.Undo.description', 'Undo'),
        smallIcon: silkIcon('page_white_cup')
    )
}


def makeSampleScriptAction = { id, name ->
   noparent {
      action(id: "${id}Action",
         name: name,
         closure: { model.currentSampleId = id; controller.runSampleScriptAction(it) },
         smallIcon: silkIcon('script_gear')
      )
   }
   doOutside {
      model.samples[id] = Thread.currentThread().contextClassLoader.
                   getResourceAsStream("samples/${id}.txt").text
   }
   return this."${id}Action"
}


    
application(title: 'movdata',
    size: [600,400],
    pack: true,
    location: [350,350],
    locationByPlatform:true,
    iconImage: imageIcon('/griffon-icon-48x48.png').image,
    iconImages: [imageIcon('/griffon-icon-48x48.png').image,
               imageIcon('/griffon-icon-32x32.png').image,
               imageIcon('/griffon-icon-16x16.png').image]) {
    // add content here

    menubar = menuBar {
        menu(text: app.getMessage('application.menu.File.name',' File'), 
             mnemonic: app.getMessage('application.menu.File.mnemonic', 'F')) {
            menuItem(newAction)
        }
        menu(text: app.getMessage('application.menu.Edit.name', 'Edit'), 
             mnemonic: app.getMessage('application.menu.Edit.mnemonic', 'E')) {
            menuItem(undoAction)
            menuItem(redoAction)
        }
    }    

    p = panel
    {
    
        migLayout(layoutConstraints: 'fill')
        splitMainPane = splitPane(name:'splitMainPane') {
            wathlistPanel = tabbedPane(tabPlacement: JTabbedPane.TOP) { 
                label('mainwatchlist', title:'List', tabToolTip:'List!')
            }
            graphlist = tabbedPane(tabPlacement: JTabbedPane.TOP) {
                label('mainchart', title:'Chart', tabToolTip:'Chart!')
            }
        }
    }
    
    CSSDecorator.decorate("default",p)
}
